package com.project.lk.nurseapp.common.view.chat;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;

import com.project.lk.nurseapp.R;
import com.project.lk.nurseapp.base.UrlContants;
import com.project.lk.nurseapp.utils.AppManager;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import fm.jiecao.jcvideoplayer_lib.JCUserAction;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;
/**
 * 功能介绍：
 * 项目名：
 * 模块名称：
 * 作者：LK
 * 日期：2018/1/9
 * 修改日期：
 */
public class VideoActivity extends AppCompatActivity {
    private Unbinder mBind;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(getLayoutId());
        //设置全屏
//        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
//                WindowManager.LayoutParams.FLAG_FULLSCREEN);
//        getWindow().addFlags(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        getWindow().addFlags(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        AppManager.getAppManager().addActivity(this);
        //绑定黄油刀
        mBind = ButterKnife.bind(this);
        init();

    }

    private void init() {
        initData();
        initView();
    }
    @BindView(R.id.videoView)
    JCVideoPlayerStandard mVideoView;
    public String testUrl = "http://gslb.miaopai.com/stream/ed5HCfnhovu3tyIQAiv60Q__.mp4";
    protected void initData() {
      String url=  getIntent().getStringExtra("video");
        //播放地址
        mVideoView.setUp(url, JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "");
//        mVideoView.setUp(testUrl, JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "");
        //自动播放
        mVideoView.startVideo();
        mVideoView.requestFocus();
        mVideoView.setJcUserAction(new JCUserAction(){
            @Override
            public void onEvent(int type, String url, int screen, Object... objects) {
                switch (type) {
                    case JCVideoPlayer.CURRENT_STATE_PLAYING:

                        break;
                    case JCVideoPlayer.CURRENT_STATE_PAUSE:

                        break;

                }
            }
        });
    }

    protected void initView() {

    }

    protected int getLayoutId() {
        return R.layout.activity_video;
    }


    @OnClick(R.id.back)
    public void onViewClicked() {
        AppManager.getAppManager().finishActivity();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        if (mVideoView!=null) {
            mVideoView.release();
            mVideoView=null;
        }
        if (mBind != null) {
            mBind.unbind();
        }
    }


}
